package com.atqinke.designpattern.creationtype.prototype.copy;

import org.springframework.util.SerializationUtils;

import java.io.Serializable;

/**
 * @BelongsProject: BasicConnection
 * @BelongsPackage: com.atqinke.DesignPattern.creation.prototype
 * @Author: NieHk
 * @CreateTime: 2022-08-25  23:18
 * @Description: 深拷贝类
 * @Version: 1.0
 */
public class DeepCopy implements Cloneable,Serializable{
    private Other other = new Other("李四");

    public Other getOther() {
        return other;
    }

    public void setOther(Other other) {
        this.other = other;
    }

    //通过序列化拷贝
    public DeepCopy DeepClone(){
        byte[] serialize = SerializationUtils.serialize(this);
        return (DeepCopy)SerializationUtils.deserialize(serialize);
    }
}
